import Vue from 'vue'
import Router from 'vue-router'


Vue.use(Router)

let router =  new Router({
  mode: 'history',
  routes: [
    {
      path: '/',
      name: 'home',
      meta: { title: '首页' },
      component: () => import('../pages/home.vue')
    },
    {
      path: '/daily',
      name: 'daily',
      meta: { title: '日报' },
      component: () => import('../pages/daily.vue')
    },
    {
      path: '/detaile/:id',
      name: 'detail',
      meta: {title: '详情页'},
      props: true,
      component: () => import('../pages/detaile.vue')

    }
  ]
})

router.beforeEach( (to, from, next) => {
  window.document.title = to.meta.title;
  next();
})
router.afterEach( (to, from, next) => {
  window.scrollTo(0, 0);
})
export default router
